/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : levelLogic
	/// </summary>
	public class LevelBuffChangePOD : IPOD 
    {
        public readonly static Func<LevelBuffChangePOD> FACTORY = () => new LevelBuffChangePOD();
		public static Func<LevelBuffChangePOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 对应枚举LevelBuffHostType
        /// </summary>
		public int hostType;
		/// <summary>
        /// 根据hostType判断，例如如果targetType是LevelBuffHostType.Entity，则hostId代表实体id
        /// </summary>
		public long hostId;
		/// <summary>
        /// 对应枚举LevelBuffOperationType
        /// </summary>
		public int opType;
		/// <summary>
        /// 增加或改变的buff pod，没有为null
        /// </summary>
		public LevelBuffPOD addOrChangePOD;
		/// <summary>
        /// 移除的buff cid，没有就是0，addOrChangePOD和removeCid可能会同时有值（覆盖buff）
        /// </summary>
		public int removeCid;
		
		
		
		/*-- constructors --*/
		public LevelBuffChangePOD() {}
		public LevelBuffChangePOD(int hostType, long hostId, int opType, LevelBuffPOD addOrChangePOD, int removeCid) {
			this.hostType = hostType;
			this.hostId = hostId;
			this.opType = opType;
			this.addOrChangePOD = addOrChangePOD;
			this.removeCid = removeCid;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(hostType);
            _out.Write_long(hostId);
            _out.Write_int(opType);
            _out.Write_pod(addOrChangePOD);
            _out.Write_int(removeCid);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            hostType = _in.Read_int();
            if(!_in.HasRemaining()) return;
            hostId = _in.Read_long();
            if(!_in.HasRemaining()) return;
            opType = _in.Read_int();
            if(!_in.HasRemaining()) return;
            addOrChangePOD = _in.Read_pod<LevelBuffPOD>(LevelBuffPOD.DynamicFactory);
            if(!_in.HasRemaining()) return;
            removeCid = _in.Read_int();
        }
		
		public LevelBuffChangePOD Clone() {
            LevelBuffChangePOD o = DynamicFactory();
            o.hostType = hostType;
            o.hostId = hostId;
            o.opType = opType;
            if (addOrChangePOD != null) {
                o.addOrChangePOD = addOrChangePOD.Clone();
            }
            o.removeCid = removeCid;
            return o;
        }
        
        public void Clear() {
            hostType = default;
            hostId = default;
            opType = default;
            addOrChangePOD = default;
            removeCid = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "LevelBuffChangePOD [";
			str += "hostType=";
			str += hostType;
			str += ", hostId=";
			str += hostId;
			str += ", opType=";
			str += opType;
			str += ", addOrChangePOD=";
			str += addOrChangePOD;
			str += ", removeCid=";
			str += removeCid;
			str += "]";
			return str;
		}
		
	}
}